﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SpeakTechnology.LogicOfBussiness;
namespace SpeakTechnology.Presentation
{
    public partial class User : Form
    {
        public User()
        {
            InitializeComponent();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ControlUser c = new ControlUser();
            c.Show();
            c.Visible = true;
            this.Visible = false;
        }

       
        private void NEWP_Click(object sender, EventArgs e)
        {
            BoxName.Clear();
            BoxLast.Clear();
            BoxUser.Clear();
            BoxPass.Clear();

        }

        private void SAVE_Click(object sender, EventArgs e)
        {
            C_usuario usa = new C_usuario();
            if (usa.validar_name_last_user_pass(BoxName.Text, BoxLast.Text, BoxUser.Text, BoxPass.Text))
            {
                MessageBox.Show(" What Have you  ingress the name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (usa.save_user(BoxName.Text, BoxLast.Text, BoxUser.Text, BoxPass.Text))
                {
                    MessageBox.Show("The user is stored", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(" Existing User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void BoxName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void BoxLast_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void BoxUser_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void BoxPass_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsDigit(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        
    }
}
